''' 导出图片 '''

from pymongo import MongoClient
from gridfs import *    #引入了pymongo即可以直接引入

#链接mongodb  实例
client = MongoClient(host="mongodb://127.0.0.1",port=27017)
myset = client['good']

#给予girdfs模块写出
gridfs = GridFS(myset,collection='fs')

#获取图片数据
count = 0
for i in gridfs.find():
    count += 1
    print(count)
    data = i.read()  #获取文件数据
    outf = open(str(count) +'cs.png','wb')  #创建文件
    outf.write(data)  #写入文件
    outf.close()